
const ProjeceModel = require("./models/ProjectModel");

// 添加项目
module.exports.addProject = async function (info) {
    const data = await ProjeceModel.create(info);
    return data ? data.toJSON() : data;
}

// 获取所有项目
module.exports.getProject = async function () {
    const result = await ProjeceModel.findAndCountAll();
    return JSON.parse(JSON.stringify(result));
}

// 删除项目
module.exports.deleteProject = async function (id) {
    return await ProjeceModel.destroy({
        where: {
            id
        }
    })
}

// 修改项目
module.exports.updateProject = async function (id, ProjectInfos) {
    await ProjeceModel.update(ProjectInfos, {
        where: {
            id
        }
    });
    const result = await ProjeceModel.findByPk(id);
    return result ? result.toJSON() : result;
}